﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Xml;

namespace Mdv.wssAddins
{
    public partial class XmlEditor : System.Drawing.Design.UITypeEditor
    {
        public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return System.Drawing.Design.UITypeEditorEditStyle.Modal;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (provider != null))
            {
                IWindowsFormsEditorService editorService = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null && value is XmlNode)
                {
                    XmlEditorForm formEditor = new XmlEditorForm(editorService);
                    formEditor.Value = (XmlNode) value;
                    editorService.ShowDialog(formEditor);
                    return formEditor.Value;
                }
            }
            return base.EditValue(context, provider, value);
        }
    }
}